package ro.imc.rest.client.display.util;

import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.event.dom.client.ClickHandler;
import com.google.gwt.user.client.ui.Button;
import com.google.gwt.user.client.ui.DialogBox;
import com.google.gwt.user.client.ui.HTML;
import com.google.gwt.user.client.ui.VerticalPanel;

public final class DialogForm extends DialogBox {
	
	private DialogForm () {
		
	}
	private DialogForm(String title, String html, String msg, String tip) {
		final DialogBox here = this;
		this.setText(title);
		this.setAnimationEnabled(true);
		Button closeButton = new Button("Close");
		closeButton.addClickHandler(new ClickHandler() {

			@Override
			public void onClick(ClickEvent event) {
				here.clear();
				here.hide();

			}
		});
		HTML message = new HTML();
		HTML tips = new HTML();
		message.setText(msg);
		tips.setText(tip);
		VerticalPanel dialogVPanel = new VerticalPanel();
		dialogVPanel.addStyleName("dialogVPanel");
		dialogVPanel.setSpacing(23);
		dialogVPanel.add(new HTML("<b>" + html + "</b>"));

		dialogVPanel.add(message);

		dialogVPanel.add(tips);
		dialogVPanel.setHorizontalAlignment(VerticalPanel.ALIGN_RIGHT);
		dialogVPanel.add(closeButton);
		this.setWidget(dialogVPanel);
		this.center();
		this.show();
	}
	
	public static void displayDialog (String title, String html, String msg, String tip) {
		new DialogForm(title, html, msg, tip);
	}
	public static void displayDialog (String title, String html, String tip) {
		new DialogForm(title, html, "", tip);
	}
	

}